package com.dbuil.bleshoes.ui.activity;

import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.dbuil.bleshoes.R;
import com.dbuil.bleshoes.base.BaseActivity;
import com.dbuil.bleshoes.ui.view.NofastClickTextview;
import com.dbuil.bleshoes.utils.banner.BannerBean;
import com.dbuil.bleshoes.utils.banner.XBannerUtils;
import com.stx.xhb.androidx.XBanner;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class ProductDetailActivity extends BaseActivity {
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.tv_top_title)
    TextView tvTopTitle;
    @BindView(R.id.tv_top_right)
    TextView tvTopRight;
    @BindView(R.id.img_top_right)
    ImageView imgTopRight;
    @BindView(R.id.product_banner)
    XBanner productBanner;
    @BindView(R.id.tv_danwei)
    TextView tvDanwei;
    @BindView(R.id.tv_productdetail_price)
    TextView tvProductdetailPrice;
    @BindView(R.id.tv_old_price)
    TextView tvOldPrice;
    @BindView(R.id.tv_sale_count)
    TextView tvSaleCount;
    @BindView(R.id.tv_kefu)
    NofastClickTextview tvKefu;
    @BindView(R.id.tv_gouwucar)
    NofastClickTextview tvGouwucar;
    @BindView(R.id.tv_addtocar)
    NofastClickTextview tvAddtocar;
    @BindView(R.id.tv_buy)
    NofastClickTextview tvBuy;

    @Override
    public int getLayoutId() {
        return R.layout.activity_product_detail;
    }

    @Override
    public void initView() {
        super.initView();
        tvTopTitle.setText(getString(R.string.productdetail));

        tvOldPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);//中划线
        tvOldPrice.getPaint().setAntiAlias(true); //去掉锯齿

        ViewGroup.LayoutParams layoutParams = productBanner.getLayoutParams();
        layoutParams.height = ScreenUtils.getScreenWidth();
        productBanner.setLayoutParams(layoutParams);

    }

    @Override
    public void initData() {
        super.initData();
        initBanner();
    }

    private void initBanner() {
        List<BannerBean> bannerdata = new ArrayList<>();
        for (String s : getUrl().subList(6, 11)) {
            bannerdata.add(new BannerBean(s, "", ""));
        }
        XBannerUtils.initBanner(this, productBanner, bannerdata, false);
        XBannerUtils.setOnBannerItemClick((bannerBean, position) -> ActivityUtils.startActivity(HomeActivity.class));
    }





    @OnClick({R.id.img_back, R.id.tv_kefu, R.id.tv_gouwucar, R.id.tv_addtocar, R.id.tv_buy})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                this.finish();
                break;
            case R.id.tv_kefu:
                break;
            case R.id.tv_gouwucar:
                break;
            case R.id.tv_addtocar:
                break;
            case R.id.tv_buy:
                break;
        }
    }
}
